import api from "../../../common/api";

// pages/gatherHouse/productTutorial/prodctTutorial.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    houseShare: [
    // {
    //   image: '/images/defaultImgSmall.jpg',
    //   title: '微信海报分享教程',
    //   url: 'https://media.shulanfd.com/20200715/dbd39869eeb541b5bbada1d98750bd42.mp4'
    // },
  ],
  houseLead: [
]
  },
  playVideo(e){
    let url = e.currentTarget.dataset.url;
    // let url = this.CTE(e.currentTarget.dataset.url);
    let date = e.currentTarget.dataset.date;
    let title = e.currentTarget.dataset.title;
    let typename = e.currentTarget.dataset.typename;
    console.log(e)
    wx.navigateTo({
      // url: '/pages/house/RentalHouseDetail/audioPlayPage/audioPlayPage?src='+url,
      url: '/pages/gatherHouse/playVideo/playVideo?date='+date+'&url='+url+'&title='+title+'&typename='+typename,
    })
  },
  queryPmReferenceDetailInfoByRefCode(){
    api.queryPmReferenceDetailInfoByRefCode({
      "refCode": "ProductDescription"
    }, res => {
      try {
        let content = res.data.content.map( v => {
          let refDetailValue = JSON.parse(v.refDetailValue).map( n => {
            n.url = this.CTE(n.url)
            return n
          })
          return {
            refDetailName: v.refDetailName,
            refDetailValue: refDetailValue
          }
        })
        this.setData({
          content
        })
      } catch (error) {
        
      }
    })
  },
  videometa(e) {
    var that = this;
    //获取系统信息
    wx.getSystemInfo({
      success (res) {
        //视频的高
        var height = e.detail.height;
        
        //视频的宽
        var width = e.detail.width;
 
        //算出视频的比例
        var proportion = height / width;
 
        //res.windowWidth为手机屏幕的宽。
        var windowWidth = res.windowWidth;
 
        //算出当前宽度下高度的数值
        height = proportion * 625;
        that.setData({
          height,
          width:windowWidth
        });
      }
    })
  },
  CTE(U) {
    let url = U;
    url = url.split('/');
    let pattern = new RegExp("[\u4E00-\u9FA5]+");
    url = url.map(v=>{
      if(pattern.test(v)){
        v=encodeURIComponent(v)
      }
      return v
    })
    url = url.join('/')
    return url
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.showShareMenu({
      withShareTicket: true,
    });
    this.queryPmReferenceDetailInfoByRefCode();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    // console.log(this.CTE('https://media.shulanfd.com/static/jjrjs/功能介绍/树懒经纪人功能介绍.mp4'),999)
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    let userId = ''
    try {
      userId = getApp().globalData.sessionUser.id
    } catch (error) {}
    return {
      title: '产品教程',
      imageUrl: '../images/share.png',
      path: `/pages/gatherHouse/productTutorial/prodctTutorial?agentId=${userId}`
    }
  }
})